package com.bilibili.juc.me;

import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;

public class ConcurrentSkipListMapDemo {
    public static void main(String[] args) {
        ConcurrentSkipListMap<Integer,String> map = new ConcurrentSkipListMap<>();
        map.put(100,"beijing");
        map.put(101,"shenzhen");
        map.put(99,"shanghai");
        map.put(120,"tianjin");
        map.put(88,"shijiazhuang");
        //{88=shijiazhuang, 99=shanghai, 100=beijing, 101=shenzhen, 120=tianjin}
        System.out.println(map);

        ConcurrentNavigableMap<Integer, String> headMap = map.headMap(100, true);
        // {88=shijiazhuang, 99=shanghai, 100=beijing}
        System.out.println(headMap);

        ConcurrentNavigableMap<Integer, String> tailMap = map.tailMap(100, true);
        // {100=beijing, 101=shenzhen, 120=tianjin}
        System.out.println(tailMap);


    }
}
